#include <stdlib.h>
#include <string.h>
#include "tst/bas/test_container_utility.h"

void testComplexStructDestroy(T_TestComplexStruct *ptTestComplexStruct)
{
    free(ptTestComplexStruct->ptData);
}

bool testComplexStructLess(const T_TestComplexStruct *ptTestComplexStructFirst,
                           const T_TestComplexStruct *ptTestComplexStructSecond)
{
    return (ptTestComplexStructFirst->i < ptTestComplexStructSecond->i);
}

int testComplexStructCopy(T_TestComplexStruct *ptTestComplexStructTo,
                          const T_TestComplexStruct *ptTestComplexStructFrom)
{
    ptTestComplexStructTo->i = ptTestComplexStructFrom->i;
    ptTestComplexStructTo->f = ptTestComplexStructFrom->f;

    ptTestComplexStructTo->ptData = (T_TestSimpleStruct *)malloc(sizeof(T_TestSimpleStruct));
    if (NULL == ptTestComplexStructTo->ptData)
    {
        return -1;
    }
    memcpy(ptTestComplexStructTo->ptData, ptTestComplexStructFrom->ptData,
           sizeof(T_TestSimpleStruct));

    return 0;
}

int testComplexStructInit(T_TestComplexStruct *ptTestComplexStruct, void *pvNULL)
{
    memset(ptTestComplexStruct, 0, sizeof(T_TestComplexStruct));
    ptTestComplexStruct->i = 1;
    ptTestComplexStruct->ptData = (T_TestSimpleStruct *)malloc(sizeof(T_TestSimpleStruct));

    return 0;
}
